﻿using Newtonsoft.Json.Linq;

namespace Art_To_Eagle.Lib.EagleLib.Structure
{
    class Folder
    {
        public string ID { private set; get; }
        public string Name { private set; get; }
        public string PinYin { private set; get; }
        public string Description { private set; get; }
        public long ModificationTime { private set; get; }
        public int ImageCount { private set; get; }
        public int DescendantImageCount { private set; get; }
        public string[] Tags { private set; get; }
        public string[] ExtendTags { private set; get; }
        public ChildFolder[] Children { private set; get; }

        public Folder(JToken data)
        {
            ID = (string)data["id"];
            Name = (string)data["name"];
            PinYin = (string)data["pinyin"];
            Description = (string)data["description"];
            ModificationTime = (long)data["modificationTime"];
            ImageCount = (int)data["imageCount"];
            DescendantImageCount = (int)data["descendantImageCount"];
            Tags = new string[0];
            ExtendTags = new string[0];
            var child = (JArray)data["children"];
            Children = new ChildFolder[child.Count];
            for (int i = 0; i < child.Count; i++)
            {
                Children[i] = new ChildFolder(child[i]);
            }
        }
    }
}
